﻿using SiliconSelect.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SiliconSelect.Views
{
    /// <summary>
    /// LoginView.xaml 的交互逻辑
    /// </summary>
    public partial class LoginView : Window
    {
        public LoginView()
        {
            InitializeComponent();
            DataContext = new LoginViewModel();
        }

        /// <summary>
        /// 鼠标移动的时候窗口跟着移动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LoginWindow_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                this.DragMove();
            }
        }

        /// <summary>
        /// 用户输入状态发生改变的时候,去清楚错误信息,免得一直在那里引起干扰
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnInputChanged(object sender, RoutedEventArgs e)
        {
            if (DataContext != null)
            {
                LoginViewModel viewModel = (LoginViewModel)DataContext;
                viewModel.ErrorMsg = string.Empty;
            }
        }
    }
}
